import Vue from 'vue'
import VueRouter from 'vue-router'

/* // 电影模块路由
import move from './routes/move'
// 公共路由模块
import common from './routes/common' */

// 1-扫描的目录,2-是否递归,3-拓展名
const routelist = require.context('./routes', false, /\.js$/)
// console.log(routelist.keys());
const routes = routelist.keys().reduce((p, item) => {
  // console.log(routelist(item).default);
  let listone = routelist(item).default
  if (listone) {
    Array.isArray(listone) ? p.push(...listone) : p.push(listone)
  }
  // console.log(p);
  return p
}, [])


Vue.use(VueRouter)

/* const routes = [
  move,
  ...common,
] */

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
